package com.third.bank.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.third.bank.Dto.TransactionRecordsDto;
import com.third.bank.entity.TransactionRecords;
import com.third.bank.service.TransactionRecordsService;
import com.third.bank.util.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 交易记录表controller
 */
@Api(value = "/transactionRecords", tags = {"交易记录表controller"})
@RestController
@RequestMapping("/transactionRecords")
public class TransactionRecordsController {

    @Autowired
    private TransactionRecordsService transactionRecordsService;

    @ApiOperation(value = "查询用户交易流水", httpMethod = "POST")
    @PostMapping("page")
    @
            ApiImplicitParam(name = "Authorization", value = "Authorization", required = true, dataType = "String", paramType = "header")
    public BaseResponse<Page<TransactionRecords>> pageTransactionRecords(@RequestBody TransactionRecordsDto transactionRecordsDto,
                                                                         HttpServletRequest request) {
        String authorization = request.getHeader("Authorization");

        return transactionRecordsService.getPageTransactionRecords(transactionRecordsDto, authorization);
    }

}
